﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL_Class;

namespace NLLSite.Administrator.UserControl
{
    public partial class AddNewMenu : System.Web.UI.UserControl
    {
        Menubar menu = new Menubar();
        DAL_Class.Menu me;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void BtnAdd_Click(object sender, EventArgs e)
        {
            me = new DAL_Class.Menu();
            me.Name = TxtMenu.Text;
            me.ParrentID = 0;
            if (LbxMenuid.SelectedValue != "") 
            {
                me.ParrentID = Convert.ToInt32(LbxMenuid.SelectedValue);
            }
           me.Position =HttpUtility.HtmlDecode(Ddlposi.SelectedValue);
           if(CbcStatu.Checked){me.Status = true;}else{me.Status = false;}
           me.SortNumber = Convert.ToInt32(TxtSortNo.Text);
           me.MetaTitle = TxtMetatit.Text;
           me.MetaDescription = TxtMetades.Text;
           me.MetaKeywords = TxtMetakey.Text;
           me.MetaRobots = TxtMetaTo.Text;
           me.MetaAuthor = TxtMetaaut.Text;
           LblCheck.Text= menu.AddNewMenu(me);
           Response.Redirect("QuanlyMenu.aspx");
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            TxtMenu.Text = string.Empty;
            TxtMetaaut.Text = string.Empty;
            TxtMetades.Text = string.Empty;
            TxtMetakey.Text = string.Empty;
            TxtMetatit.Text = string.Empty;
            TxtMetaTo.Text =string.Empty;
            TxtSortNo.Text = string.Empty;
            LblCheck.Text = string.Empty;
        }

        protected void Ddlposi_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Ddlposi.SelectedValue == "Chủ Đề")
            {
                LbxMenuid.DataSourceID = "LinqDataSource3";
                LbxMenuid.DataBind();
            }
            else { LbxMenuid.Items.Clear(); }
        }
    }
}